package com.shigen.demo.atguigu;

import java.lang.ref.WeakReference;

/**
 * 弱引用
 *
 * @author shigenfu
 * @date 2022/5/26 12:56 下午
 */
public class WeakReferenceDemo {

  public static void main(String[] args) {
    Object o = new Object();
    WeakReference<Object> weakReference = new WeakReference<>(o);
    System.out.println(o + " " + weakReference.get());
    o = null;
    System.gc();
    System.out.println(o + " " + weakReference.get());


  }

}
